import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import './styles/element-variables.scss'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
// 折线图
import ECharts from 'vue-echarts'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'
import VueBus from 'vue-bus'

import 'echarts/map/js/china'
Vue.prototype.$echarts = ECharts

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
// 时间插件的样式
import moment from 'moment'
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
import { validAuth } from '@/utils/validate'
// 语言
import i18n from './lang'
import ElementLocale from 'element-ui/lib/locale'
Vue.prototype.validAuth = validAuth
Vue.use(preview)
Vue.use(ElementUI, { locale })

Vue.config.productionTip = false
// 时间过滤器
Vue.filter('dateFilter', (input, format = 'YYYY-MM-DD HH:mm:ss') => {
  return moment(input).format(format)
})

Vue.component('chart', ECharts)
Vue.use(VueBus)
ElementLocale.i18n((key, value) => i18n.t(key, value))
Vue.use(ElementUI, {
  size: Cookies.get('size') || 'medium',
  i18n: (key, value) => i18n.t(key, value)
})

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
